<?php
include('../includes/definer.php');
include(INC.'php/bootstrap.php');
include(INC.'php/clases/array_column.php');

$visitas = Doctrine_Query::create()
        ->select('v.id, c.id as catid, c.value as label, count(v.id) as data')
        ->from('Visita as v')
        ->innerJoin('v.categoria as c')
        ->where('DATE_FORMAT(v.fecha, "%Y-%m-%d") >= DATE_SUB(NOW(), INTERVAL 14 DAY)')
        ->andWhereNotIn('c.slug', array('home', 'about-me', 'prensa'))
        ->groupBy('c.id')
        ->execute(array(), Doctrine::HYDRATE_ARRAY)
;
header("Content-type: application/json");
echo(json_encode($visitas, JSON_NUMERIC_CHECK));
?>
